package com.dlnu.sujiwords.controller;

import com.dlnu.sujiwords.domain.client.AjaxResult;
import com.dlnu.sujiwords.domain.pojo.Role;
import com.dlnu.sujiwords.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@RequestMapping("/SuJiWords/role")
public class RoleController {
    @Resource
    private IRoleService service;
    @GetMapping("/selRole")
    public AjaxResult selRole(){
        return service.selRole();
    }

    @RequestMapping("/createRole")
    @ResponseBody
    public AjaxResult creRole(@RequestBody Role r){
        return service.addRole(r);
    }

    @RequestMapping("/updateRole")
    @ResponseBody
    public AjaxResult updRole(@RequestBody Role r){
        return service.updRole(r);
    }

    @DeleteMapping("delRole/{delRole}")
    @ResponseBody
    public AjaxResult delRole(@PathVariable("delRole") Byte del){
        return service.delRole(del);
    }
}
